package com.iafme.service.impl;

import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.iafme.mapper.OrderNoTypeMapper;
import com.iafme.model.OrderNoType;
import com.iafme.service.OrderNoTypeService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * @author summer
 * @version 1.0
 * @date 2025/4/2 14:27
 */
@Service
@Transactional(rollbackFor = Exception.class)
public class OrderNoTypeServiceImpl extends ServiceImpl<OrderNoTypeMapper, OrderNoType> implements OrderNoTypeService {

    @Override
    public void updateOrderType(String oldOrderNo, String newOrderNo) {
        LambdaQueryWrapper<OrderNoType> eq = Wrappers.lambdaQuery(OrderNoType.class).eq(OrderNoType::getOrderNo, oldOrderNo);
        OrderNoType orderNoType = this.getOne(eq);
        if(ObjectUtil.isNotEmpty(orderNoType)){
            orderNoType.setOrderNo(newOrderNo);
            this.updateById(orderNoType);
        }
    }
}
